Passed
Push — master ( 649d64...cc116d )
by Dmytro
02:15 queued 11s
created

utils.js ➔ checkError   A

Complexity

Conditions 2

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 9
c 0
b 0
f 0
rs 10
cc 2
1
import { assert } from 'chai';
2
import md5 from 'md5';
3
import fs from 'fs-extra';
4
5
export async function checkError(promise, type, message) {
6
    try {
7
        await promise;
8
        assert.fail();
9
    } catch (error) {
10
        assert.equal(error.name, type, error.toString());
11
        assert.match(error.message, new RegExp(message), error.toString());
12
    }
13
}
14
15
export async function checkMD5(file, hash) {
16
    const buff = await fs.readFile(file);
17
18
    assert.equal(md5(buff), hash, `${Buffer.byteLength(buff)}: ${buff.toString()}`);
19
}
20